#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<stdlib.h>

typedef struct student
{
	int _sno;
	char _name[20];
	int _score[3];
}Student;

int main()
{
	//FILE* pf = fopen("f1.txt", "wb");
	FILE* pf = fopen("f1.txt", "rb");
	Student arr[100] = { 0 };
	if (NULL == pf)
	{
		perror("fopen");
		return 1;
	}
	/*int i = 0;
	for (i = 0; i < 100; i++)
	{
		scanf("%d", &(arr[i]._sno));
		if ((arr[i]._sno) != 0)
		{
			scanf("%s%d%d%d", arr[i]._name, &(arr[i]._score[0]), &(arr[i]._score[1]), &(arr[i]._score[2]));
			fwrite(&(arr[i]), sizeof(Student), 1, pf);
		}
		else
		{
			break;
		}
	}*/
	Student arr2[100] = { 0 };
	fread(&(arr2[0]), sizeof(Student), 1, pf);
	int i = 0;
	while (!feof(pf))
	{
		int sum = arr2[i]._score[0] + arr2[i]._score[1] + arr2[i]._score[2];
		float average = sum / 3.0;
		printf("%-6d%-6s%-6d%-6d%-6d%-6d%-6.2f\n",
			arr2[i]._sno,
			arr2[i]._name,
			arr2[i]._score[0],
			arr2[i]._score[1],
			arr2[i]._score[2], sum, average);
		i++;
		fread(&(arr2[i]), sizeof(Student), 1, pf);
	}
	fclose(pf);
	pf = NULL;
	return 0;
}



#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
int main()
{
	//FILE* pf = fopen("num.txt", "wb");
	FILE* pf = fopen("num.txt", "rb");
	if (NULL == pf)
	{
		perror("fopen");
		return 1;
	}
	/*int i = 0;
	int j = 0;
	for (i = 2; i <= 100; i++)
	{
		int flag = 0;
		for (j = 2; j < i; j++)
			if (0 == i % j)
			{
				flag++;
				break;
			}
		if (0 == flag)
		{
			int* p = &i;
			fwrite(p, sizeof(int), 1, pf);
		}
	}*/
	int arr[100] = { 0 };
	fread(&(arr[0]), sizeof(int), 1, pf);
	int i = 0;
	while (!feof(pf))
	{
		printf("%-4d", arr[i]);
		i++;
		if (i % 6 == 0)
			printf("\n");
		fread(&(arr[i]), sizeof(int), 1, pf);
	}
	fclose(pf);
	pf = NULL;
	return 0;
}